package com.xltq.entity;

import java.util.List;
import java.util.List;

public class PageBean<T> {
    //分页5要素
    //存储的数据(当前页要展示数据),当前页数, 每页展示条数,总条数,总页数
    private List<T> List;//存储的数据
    private int currentPage;//当前页数
    private int pageSise;//每页展示的条数
    private long totalCount;//总条数
    private int totalPage;//总页数


    public PageBean(java.util.List<T> list, int currentPage, int pageSise, long totalCount) {
        List = list;
        this.currentPage = currentPage;
        this.pageSise = pageSise;
        this.totalCount = totalCount;
    }

    //直接计算出总页数
    public int getTotalPage() {
        //ceil这个方可以向上舍余数 得到整数
        //例如  13/3 == 4...1   -->计算出整数 5
        //      12/3 == 4  --->计算出整数 4
        return (int) Math.ceil(totalCount*1.0/pageSise);
    }

    public java.util.List<T> getList() {
        return List;
    }

    public void setList(java.util.List<T> list) {
        List = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSise() {
        return pageSise;
    }

    public void setPageSise(int pageSise) {
        this.pageSise = pageSise;
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }



    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }
}
